<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="test">
    <h2>显示格式化的日期时间</h2>
    <p>{{date}}</p>
    <p>完成版：{{date | dateString}}</p>
    <p>年月日: {{time | dateString('YYYY-MM-DD')}}</p>
</div>
<script type="text/javascript" src="../js/vue.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/moment.js/2.22.1/moment.js"></script>
<script type="text/javascript">
    //自定义过滤
    Vue.filter("dateString",function (value,format='YYYY-MM-DD HH:mm:ss') {
        return moment(value).format(format);
    });

    new Vue({
       el: "#test",
       data: {
           date: new Date()
       }
    });
</script>
</body>
</html>